﻿using DAL.Entities;
using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL.Configurations
{
    public class EmployeeConfiguration : EntityTypeConfiguration<Employee>
    {
        public EmployeeConfiguration()
        {
            ToTable("employee").HasKey(x => x.EmployeeId);
            Property(x => x.DisplayName).HasMaxLength(100);
            Property(x => x.PhoneNumber).HasMaxLength(100);
            Property(x => x.IdentityNumber).HasMaxLength(100);
            Property(x => x.EmployeeType).HasMaxLength(50);
            Property(x => x.DepartmentId).HasMaxLength(100);
            Property(x => x.DepartmentName).HasMaxLength(200);
            Property(x => x.Gender).HasMaxLength(10);
            Property(x => x.Hometown).HasMaxLength(200);
            Property(x => x.EmployeeNumber).HasMaxLength(100);
            Property(x => x.Post).HasMaxLength(100);

            HasMany(x => x.InOuts).WithRequired(x => x.Employee).HasForeignKey(x => x.EmployeeId);

            HasIndex(x => x.DepartmentId);
        }
    }
}
